﻿/*
 * ======================================================================
 *                           Modern Warfare3 Launcher
 * Copyright 2011-2012
 * Developer:Pooya parsa
 * Email:pingsft@gmail.com
 * You are ALLOWED:
 * -Read source code
 * -Use some part of source code with Full name and email of developer
 * -Release your own mod with name of develepor
 * You are NOT ALLOWD:
 * -Add cracked version of Mw3
 * -Release modified version as MW3Launcher
 * -Mirror Sourcecode
 * -Use source code without name of developer
 * Thank you for your attention
 * ======================================================================
 * */
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace MW3Launcher
{
    class window_mover
    {
        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;
        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd,
                         int Msg, int wParam, int lParam);
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();

        private Form parent;

        public double moveing_reduce_opacity = 0;



        /// <summary>
        /// Intialize class
        /// </summary>
        /// <param name="parent">the parent form for moving</param>
        public window_mover(Form _parent)
        {
            parent = _parent;
            parent.MouseDown += new MouseEventHandler(parent_MouseDown);

        }


        /// <summary>
        /// Make an objact moveable
        /// </summary>
        /// <param name="_ctrl">The Control</param>
        public void make_movable(Control _ctrl)
        {
            _ctrl.MouseDown += new MouseEventHandler(parent_MouseDown);
        }

        public void make_movable_all()
        {
            foreach (Control c in parent.Controls)
                make_movable(c);
        }

        void parent_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(parent.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
        }




    }
}
